Part Number Hot Search : 
MAZS390 2SJ319 CP382X MUR3020 090130 FST3245 INDY2200 MBRF7H50
Product Description
Full Text Search
 

To Download SH7268 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  application note r01a n0 663e j01 01 rev. 1.01 page 1 of 58 feb 16, 2012 SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller summary sh7 268 /sh726 9 spi m u lti i/o b u s co n t ro ller (spibsc) has th e fu n c tion to d i rectly fetch th e pro g ram d a ta on a serial flash m e m o ry and exec ute the m (external a d dress space re ad m ode) . t h i s ap pl i cat i on no t e of fers ex pl a n at i o n s target device sh7 268 /sh726 9 mcu ( i n t h is do cu m e n t, sh 726 8 /sh7 269 ar e d e scr i b e d as "sh7 269 ".) whe n usi n g t h i s ap pl i cat i on n o t e wi t h ot her r e nesas m c u s , care f ul eval u a t i on i s recom m ended aft e r m a ki ng m o d i ficatio n s to co m p ly with th e altern ate m c u. contents 1. introduc tion ................................................................................................................... ..................... 2 2. overview of the se rial flas h boot .............................................................................................. ....... 3 3. applications ................................................................................................................... .................... 8 4. sample progra m lis ting ......................................................................................................... ......... 26 5. us ing the do wnloader ........................................................................................................... .......... 52 6. referenc es ..................................................................................................................... ................. 57 r01an 0 6 63ej 010 1 rev. 1.01 f eb 16, 20 12 http://
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 2 of 58 feb 16, 2012 1. introduction 1.1 specifications b oot m ode 3 al l o ws b o o t i n g t h e s h 72 6 9 fr o m i t s seri al fl ash m e m o ry (he r ein after called seri al fl as h bo ot ). the seri al fl ash b oot p r o g r esses a n d e x e c ut es t h e l o a d e r pr og ram s i n th e h i gh -sp e ed i n tern al ram. at th is tim e th e ex tern al ad dress sp ace read m o d e for t h e spi m u lti i/ o b u s co n t ro ller (s pibsc) is in v a lid. th is m o d e is en ab led b y th e l o ad er pr o g ram . thi s a ppl i cat i o n not e desc ri be s ab o u t t h e l o a d er p r o g r am and a pplication program exam ples usi n g t h e ser i al flash bo ot as well as abo u t th e down l o a der to write th e l o ad er p r og ram an d app licatio n to serial flash me m o ry. 1.2 modules used ? b oot m ode (se r i a l fl ash b o o t ) ? renesas serial peripheral interface (rspi) ? spi m u lti i/o bu s con t ro ller (spibsc ) 1.3 applicable conditions mcu sh72 268/sh7269 ope r ating f r eque ncy internal clo c k (i ) : 266.67 mhz internal bus clock (b ) : 133.33 m h z periph eral clo ck 1 (p1 ) : 66.67 m h z periph eral clo ck 0 (p0 ) : 33.33 m h z integrate d de velopme n t environm ent r e ne sa s elec tr on ics co r p o r a t ion high -p erfo rm ance embed ded worksho p ver.4.07.00 c co mpile r ren esas ele c tro nics supe rh risc engi ne family c/c++ com pil er pa ckag e ver.9.03 rele a s e 02 com p iler o p tions default setting in the high -perfo rma n ce embedd ed workshop (-cpu = sh2 afp u -fpu =si ngle -obj ect = "$(config d ir)\$ ( fileleaf).o b j" -de bug -gb r =auto -chgi ncp a th -erro r path -glob a l_volat ile=0 -opt_ r a nge =all -infinite_l oop =0 -del_va c a n t_loop =0 -st r u c t_allo c=1 ?nolo g o ) serial fla s h memo ry s25fl0 32p (span sion ) x 1 1.4 related application note th e app licatio n n o t e relatin g to th is app licatio n no te is in tr o d u c ed b e low. refer t o it along with th is applicatio n no te. ? spi m u lti i/o b u s co n t ro ller serial flash m e m o ry co nn ectio n ex am p l e. 1.5 about active-low pins (signals) the sy m bol "# " su ffi xed t o t h e pi n ( o r sig n al ) nam e s i ndicates that the pi ns (or signals) a r e active-low.
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 3 of 58 feb 16, 2012 2. overview of the serial flash boot this c h apte r describes an ove r vie w of t h e se rial flash boot. 2.1 words and terms tab l e 1 lists the wo rd s and term s u s ed in t h is app l i cat i on no t e t o de scri be t h e se ri al fl ash bo ot . table 1 terms to de scri be the serial flash boo t term des c ription internal rom prog ram to b oot tran sfe r s the loade r pro gram stored in the begi nnin g of the seri al flash memo ry to the high -spee d intern al ram, and bran che s to the loade r pro gra m wh e n the mcu is booted in b o o t mode 3. this program do es not need to be created a s it is alrea d y store d in the intern al rom to bo ot in cpu. loader program enables the application program allocate d in the external address space as spi multi i/o bus space of the spi multi i/o bus controller (spibsc). branches into the entry function of the application program retaining the external address space read mode of spibsc enabled. the size of the loader program is fixed to 8 kb. create it according to the user?s system. application program a program that is created by user acco rding to the user?s system. in this application note, the application program is supposed to be allocated in the external address space of spibsc as spi multi i/o bus space. downloader a program to write the loader progra m and the application program to the serial flash memory. create it according to the user?s system.
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 4 of 58 feb 16, 2012 2.2 the serial flash boo t operation tabl e 2 l i s t s t h e ext e r n al pi ns (m d _ b o ot 2 t o m d _b o o t 0 ) t o deci de t h e b oot m ode. table 2 relationship be t w e e n the ex tern al pin se ttings a nd serial flash boot mode md_ b o ot2 md_ b o ot1 md_ b o ot0 boo t mode des cription 1 0 1 boot mode 3 boots the mcu from seri al flash mem ory con n e c ted to ren e sas se ri al periph eral interface ch a nnel 0 in b o o t m ode 3 , an i n t e r n al r o m pr og ram to bo ot t r a n s f er s the l o ade r program from the serial flas h me m o ry connected to renesa s se rial peripheral interface cha n n e l 0 (rsp i0 ) to the hig h -s pee d in tern al ram after th e power-on reset is canceled. after trans f er ri n g , s h 7 2 6 9 b r a n che s t o t h e begi nni ng o f t h e l o a d e r pr og ram . figu r e 1 show s t h e op er ation im age of the r o m program . a se ries of t h e p r o cessi n g is au to m a tica lly e x ecu ted . figure 1 operation imag e of the inter nal rom pro gram to bo o t application program loader program 8kb sh7269 internal rom program to boot internal rom to boot high - speed internal ram renesas seri al p eripheral interface channel 0 rspi0 serial flash memory h fff 80000 loader program 8kb (4 ) transfer to th e internal high speed ram (5 ) branch to the beginning of the loader program (2 ) read request (3 ) read (1 ) execute the internal rom program to boot s pi m u lti i / o bus controll er s pi bsc h fff 8 1 fff
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 5 of 58 feb 16, 2012 th e l o ad er p r og ram en ab les t h e read m o d e in th e ex tern al ad dress sp ace of spibsc. by t h is settin g, th e ap p licatio n p r og ram sto r ed in th e serial flash m e m o ry can b e allo cated in th e ex tern al ad dress sp ace. a f ter th is settin g, th e sh 7269 b r an ch es to th e en try fun c tion o f th e app licati o n pro g ram . figure 2 s h ows the ope ration i m age of th e load er pr ogr am . figure 2 operation imag e of the lo a der program application program loader program 8kb sh7269 internal rom program to boot internal r om to boot int ernal h i gh - spe ed r a m serial flash memory (7 ) set the external address space to read mode h ff f 8 0 000 loader program 8kb (8 ) f et ch the appli cati on program m ap ped i n t h e s p i m u l t i i / o bus space read request (10) execute the read instruction (6 ) execut e the loader pr ogram spibsc (9 ) read the corres ponding area to store in the read buffer of spibsc ren esas serial peripheral inter face channel 0 (r s p i 0 ) h fff 8 1 fff sp i mu lti i / o bus contro ller
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 6 of 58 feb 16, 2012 2.3 dow nloader operation th e do wn lo ader writes th e load er program o n th e h i g h -sp e ed in tern al r a m and ap p licatio n prog ram on r a m to t h e serial flash m e m o ry . fig u re 3 shows th e op eratio n im ag e o f th e d o wn lo ad er. fo r m o re in fo r m ation, re fer to ? 3. 3 downloader exam ple?. ap plicat io n pr og ra m serial flash memory ram loader program downloader loader program application program write write figure 3 operation image of the downloader
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 7 of 58 feb 16, 2012 2.4 serial flash memor y connectio n fi gu re 4 s h ow s an e x am pl e of seri al fl as h m e m o ry con n ectio n circu it and spibsc conn ectio n circu it. th e in tern al r o m p r og ram t o bo ot uses t h e r e nesas per i phe ral i n t e rfac e cha nnel 0 (r spi 0) . t h ere f o r e t h e seri al fl a s h m e m o ry sh oul d be c o n n ect ed t o r spi 0 . figure 4 serial flash memor y circuit b oot m ode 3 sh 72 69 pb20/qmi_0/qio1_0/miso0/spbmi_0/spbio1_0 pb19 / q m o _ 0/q i o0 _0/ mo si 0 / sp bm o _0/ spbi o0_ 0 pb18 / qs sl_ 0 / ssl 00 / s pbssl pb 17 / q spc lk _ 0 / r spc k0/ spb clk pb 16 /qio 3_ 0/ spbi o3_ 0 pb 15 /qio 2_ 0/ spbi o2_ 0 sc k si / i o0 w#/acc/io2 cs # s o /io 1 hold#/io3 3.3v 3.3v 3.3v 3.3v 3.3v 3.3v m d _boot0 m d _boot1 m d _boot2 3.3v 3. 3v se ri al f las h m em o r y s 25 fl 032 p 4m bytes
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 8 of 58 feb 16, 2012 3. applications th is ch ap ter describ e s abou t th e lo ad er program , the application progra m , and the downl o ade r . 3.1 loader pr ogram specifications the l o ade r program enables read m ode in the external a d dress space of t h e sp i m u lti i/o bus c o ntroller (spibsc), a n d b r an ch es to th e en try fun c tion in th e app licati o n pro g ram . 3.1.1 memor y map figu re 5 s h ow s t h e m e m o ry m a p of t h e l o ade r pr og ram . the l o ade r program is trans f e rre d from the serial flash m e m o ry to th e h igh -sp e ed ex ternal ram b y t h e in tern al rom program to boot. t h e s o urce area in the se ri al flash m e m o r y is f o r 8k b fro m ad d r ess h ? 0 000 0 000 to h ? 00 00 1 f ff. the destination a r ea is from address h? ff f 8 0000 to h?f ff8 1fff in which hi g h - spee d i n t e rnal r a m is allocated. l oader program p rogram area h ' fff 8 1 fff st ack area high- spe ed int ern al ram h ' 000 0 0 000 h ' 000 0 1 f f f h ' 00 00 200 0 te ntative vector table for exception handling h ' fff 8 1 b 0 0 h ' 180 0 00 00 sp i multi i/o bus space appli ca ti on pro gr am h ' 1800 2000 ap plication program h '1 bff ffff unavailable unavailable h ' f f f 8 000 0 e x ternal ad dress a r e a in the cpu serial f las h m emo ry figure 5 loader progr a m memor y m a p
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 9 of 58 feb 16, 2012 3.1.2 flo w char t o f the lo ader program fi gu re 6 s h ow s t h e fl o w c h art of t h e l o ade r pr og ram . for m o re in fo rm ation, refe r t o sectio ns 3. 1. 3 t o 3. 1. 11 . figure 6 loader progr a m flo w ch ar t start set the stack pointer for the loader rogram mask the interrupt set the frequency control register frqcr set the vector base register vbr r e fe r to 3 . 1 . 3 set the floating-point status/control register fpscr read transfer information in the application program enable read ode in the external address space set the stack pointer in the application program branch to the entry functions of the application program end set spi multi i/o bus controller set standby control registers 3-10 e nabl e fu ncti ons of t he p erip hera l mo dule s write-enable the large-capacity internal ram refer to 3.1.7 r e f er t o 3. 1. 6 r e f er t o 3. 1. 5 r e f er t o 3. 1. 4 r e fe r to 3 . 1 . 8 r e fe r to 3 .1 .7 r e f er t o 3. 1. 7 r ef er t o 3. 1. 1 1 r ef er t o 3. 1. 1 0 r e f er t o 3. 1. 9 spi bsc
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 10 of 58 feb 16, 2012 3.1.3 stack pointe r setting set the a d dress h' fff 8 2000 i n the stack poi n ter (r15) . the loade r progra m is allocated at the address h' fff8 0000 in t h e assem b l y lang ua ge t o av o i d t h e l o ade r pr og ram usi n g t h e u nde fi ne d st a c k poi nt er. c c a n be use d aft e r c o n f i g uri n g the stack point e r. t h e n , t h e loader pr ogr am j u m p s to th e en t r y fun c tion . 3.1.4 floating-poi nt sta t us/co n trol re giste r (fpsc r) s e tting i n th e fpscr, h ' 0 004 0 001 i s set ( sing l e-p r ecisio n op er atio n, r oun d to zer o ) . 3.1.5 vector bas e regis t er (v br) se tting the l o ade r program sets the t e ntative exce pt ion vector ta ble in vbr to sup port th e ex cep tio n a l operati o n during th e lo ad er p r o g ram is ru nn ing . the ex cep tio ns o r in terrup ts shou ld no t b e g e n e rated b e fore settin g th e vbr as the except i o n vect or t a bl e i s un de fi ne d., o n l y ve ct or n u m b ers 0 t o 18 are de fi n e d i n t h e t e nt at i v e exce pt i o n v ect or t a bl e as th e lo ad er pr ogr am d o e s n o t use in terr up ts. to em b e d ex ceptio n a l op eration s su ch as an ex tern al in terrup t during th e lo ad er p r o g ram is op erating , th e ten t ativ e excep tio n v ect o r tab l e n e ed to be ex tend ed . no te: before ex ecu ti n g ex cep tion s , th e ex cep tion v ector tab l e shou l d b e st o r ed in th e m e m o ry to allow th e c p u t o access the m e m o ry. for m o re inform ation, refe r to 6.9. 4 " n ote be fore e x ception ha ndling begi ns r u nning" in th e sh 726 8 gr oup , sh72 69 g r ou p u s er ?s man u a l f or h a r dw a r e . 3.1.6 interrup t ma sk b'1 1 1 1 is sp eci fied i n th e in terrup t m a sk lev e l b it of th e st at us regi st er ( sr ) as t h e l o a d e r pr o g ram does not su p p o r t in terru p ts in operatio n. 3.1.7 initial configuration initial configuration is necessary in t h e peripheral functions to read the a p plication progra m from the se rial flash me m o r y . 3.1.8 rea ding tra nsfe r inform ation of appl ication prog rams the l o ade r pr o g ram refers to the tra n s f er i n f o rm ation (a p p in fo ) of ap plication p r og ram in the serial flash m e m o ry to o b tain th e ex tern al add r ess in wh ich th e app l icatio n pro g ram is allo cated . tabl e 3 lists the d e tailed tran sfer i n fo rm atio n (app info) o f app licatio n p r og ra m .it is allo cated at th e ad d r ess h ' 00 00 20 00 in th e ser i al flash m e m o ry. the l o ade r p r og r a m h a nd les th e i n fo r m at io n i n th e address h ' 0 0 0 0 200 0 to h ' 0 000 20 07 i n th e ser ial f lash m e m o r y as th e tr ansf er in fo rm atio n of ap p licatio n prog ram . to acces s to the serial flas h me m o ry, spi m ode of spibsc i s adopted. table 3 transfe r inform ation (a ppinfo) of applica t ion progra m item addr ess size start address in transfe r de stination h'0 000 2 000 4 end add re ss i n transfer destination h'0000 2004 4
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 11 of 58 feb 16, 2012 3.1.9 enabling re ad mode in extern al ad dress spa c e read m o d e sho u l d b e en ab led in spibsc ex tern al add r ess sp ace to allo cate ap p licatio n p r og ram in th e spi m u lti i/o bus s p ace. 3.1.10 applica t ion program sta ck pointer s e tting th e l o ad er p r og ram sp ecifies th e v a l u e st o r ed in th e first 12 to 1 5 b y tes i n th e app licatio n prog ram in th e stack po in ter (r1 5 ) . 3.1.11 applica t ion program ju mp to the en tr y function addr ess th e l o ad er p r og ram j u m p s to th e en t r y fu n c ti o n address st o r ed in th e first 8 to 1 1 b y tes i n th e app licatio n prog ram . 3.1.12 regis t er sta t e after ex ec uting load e r program table 4 lists t h e eac h registe r state after exe cuting the l o ader program . the unlisted re gis t ers are set the sam e value as d e scr i b e d in sh 726 8 gro up, sh7 269 g r oup u ser ? s manu al f or h a rdw a r e . table 4 res i ster sta t e a f ter exe c utin g loader pr ograms (1) regis t er abbr ev iated s etting v alu e remar ks general register r0 to r1 4 indefinite prog ram c ou nter pc dep end s on t he s e tting entry function address of the appli c ation p r ogram stac k pointer sp r1 5 dep end s on t he s e tting stack p ointer setting value of the application program status regi ster sr indefinite imask bit is b?1111 vector b a se registe r vbr h'fff 8 1b00 floating - poi nt status/ cont rol re gist er fpscr h'0 004 0 001 single preci s i on ope ratio n rou nd mo de : to 0 freq uen cy co ntrol re giste r frq c r h'1015 standby co ntrol re giste r 3 stbcr3 h'1a standby co ntrol re giste r 4 stbcr4 h'0 0 standby co ntrol re giste r 5 stbcr5 h'0 0 standby co ntrol re giste r 6 stbcr6 h'0 0 standby co ntrol re giste r 7 stbcr7 h'1 2 standby co ntrol re giste r 8 stbcr8 h'0 9 system cont rol regi ster 5 syscr5 h'0f enable s writing in large - c a pac ity internal ram comm on c on t rol regi ste r cm nc r h'0 0ff f32 0 bit rate setting regi ster spbcr h'0 000 0 100 data read co ntrol re giste r drcr h'0 001 0 101 data read co mmand regi st er drcm r h'0 0eb 0000 data read e n able setting registe r dre nr h'0 222 4 7 e0 spi mode co ntrol re giste r smcr h'0 000 0 004 spi mode co mmand regi st er smcm r h'0 06b 000 0
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 12 of 58 feb 16, 2012 table 5 res i ster sta t e a f ter exe c utin g loader pr ograms (2) regis t er abbr ev iated s etting valu e remar ks spi mode ad dre s s setting regi ster smadr h'0 002 0 004 spi mode option setting re giste r smopr h'0 003 0 000 spi mode ina b le setting re giste r smenr h'0 002 0 00f comm on stat us regi ster cm nsr h'0 000 0 003 port b control regi ster 5 pbcr5 h'0 006 port b control regi ster 4 pbcr4 h'6 666 port b control regi ster 3 pbcr3 h'6 000
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 13 of 58 feb 16, 2012 3.2 application program example application program should be allocated in the spi m u lti i/o bus space as it read s in e x te rnal a d dress space rea d m ode. also no te th at t h e ap p licatio n p r og ram m u st in clud e th e addr ess i n fo rm atio n th at is referred to b y t h e lo ad er program . this section e x plains t h e proc edure t o create an a pplication program special fo r se rial flas h bo ot. 3.2.1 section alig nment th e section ali g n m en t in th e ap p licatio n prog ram is ex p l ai n e d in t h is sect io n . 1. applicatio n prog ram is ex ecuted using ex tern al address sp a ce rea d m ode. there f ore i n this application program ex am p l e, th e sectio n o f th e ap p licatio n pro g ra m is allocate d in th e spi mu lti i/o bu s sp ace. 2. the a p plication pr o g ram tran sfer inf o rm ation (ap p in fo ) re fer r e d to b y l o ad er pr ogr am , t h e en tr y fun c tio n addr ess o f th e app licati o n pro g ram an d th e settin g v a lu e of stack p o i n t er sho u l d b e alig n e d th e sectio n in th e fix e d ad dress. the t r a n s f er i n fo rm ati on of a ppl i cat i o n p r og ram (appi n f o) sh oul d be al i g n e d i n d a p p i n f sect i o n a n d t h e e n t r y fu nct i o n a d d r e ss o f t h e a ppl i c at i on pr o g ram i n d v ec ttb l sectio n.. dappinfo section an d dvecttbl sectio n sh oul d be al l o c a t e d i n t u rn f r o m t h e begi nni ng o f t h e a ppl i cat i on pr o g ram . 3. the area in the serial flash m e m o ry correspondi ng to h?1800 0000 to h?18 00 1fff in t h e spi m u lti i/o bus space is u s ed b y th e l o ad er p r og ram . th e program a r ea o f t h e ap p l i catio n p r og ram, d e fin e d area, in itialized d ata area sho u l d b e allo cated later th an h?18 00 20 00 . 4. a reset vect or table reset _ vectors s h oul d be l o cated i n t h e start a d dres s of dvectt bl section. fi gu re 7 s h ow s an e x am pl e of t h e sect i o n al i gnm ent .
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 14 of 58 feb 16, 2012 u ninit iali zed d ata area section b st ack area section s the se se ctio ns c an be all ocat ed at rando m ad dres ses. high -speed internal ram rinttbl section rpcache section loader program h ' 0 000 00 00 h ' 0 000 1 f f f h ' 00 00 20 00 h ' 18 00 000 0 spi multi i/o bus space application program h' 1800 2000 h'1 bff ffff appinfo una vaila ble external address space in the cpu serial flash memory transfer information of application program (dappinfo section) cache ope ratio n pr ogra m are a pcache section excep tion vect or t able (res et) dvecttbl section (dinttbl section) pro gram area (pr e set prg sec t i on , pi n t pr g s e ct i on, s e ct io n p ) cons tant are a c $ b sec se ct i o n , c$ d sec sec t i o n , section c ini tial ized data are a section d unused rea lloca te i n th e hig h- spe ed in tern al r am to boo t int erru pt i n hig h spe ed. h ' f f f 8 000 0 h ' f ff 8 ff ff e xcep tion vect or t able (ot her than rese t) re allo cate the cach e op erat ion i n t he h igh - spee d in tern al ra m as the cach e op erat ion s houl d be exec uted in the cach e -d isab led s pace . figure 7 ap plication pro gram sectio n alignment
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 15 of 58 feb 16, 2012 3.2.2 flo w char t th e app licatio n p r og ram in th is ap p licatio n tran sm its ch aracter string s t o ch ann e l 2 in th e serial co mm u n i catio n interface with fifo (scif2), then sets s w itching on le d using th e c h a n nel 0 in com p are m a tch tim e r. fi gu re 8 s h ow s t h e fl o w c h art of t h e a p pl i cat ion p r og ram . figure 8 ap plication pro gram flo w chart start jump to main function end resetprg. c / poweron_ reset_pc function set vbr register mask interrupt initialize section disable interrupt set register bank main. c / main function start transmit character data to scif2 configure standard i/o library (_int_iolib) infinite loop end sci f 2 setting baud ra te : 115 200 bps parity bit : no ne stop bit length : 1 set floating- point status/control register set cache (enable) initialize led (set general i/ port) set compare match timer (cmt 0) enable interrpt cmt0 main. c / int_cmt_cmi0 function start switch on/off on led end
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 16 of 58 feb 16, 2012 3.2.3 entr y function setting the e n try func tion a d dress of the applica tio n prog ram is set to tab l e nu m b er 0 o f t h e rese t vector table r eset _ vect ors . tab l e 6 lists the en try fun ction setting s . table 6 entr y function addr ess se ttings item description file nam e vecttbl.c placement section name dvecttbl table name reset_vectors table number 0 default poweron_reset_pc no te: poweron_ reset_ pc is an en try fu n c tion of t h e ap p licatio n p r og ram . 3.2.4 stack pointe r setting the st ac k poi n t er o f t h e ap pl i cat i on pr o g ram i s set t o t a bl e num ber 1 of t h e reset vect o r t a bl e r eset _ vect o r s. tabl e 7 lists th e settin g. table 7 stack pointer s e tting s item description file name vecttbl.c placem ent section name dvecttbl table name reset_vectors table n umber 1 default _se c end ("s") 3.2.5 section initialization th e section is in itialized b y ex ecu ting t h e sectio n in itializat io n rou tin e ( initsct fun c tio n) us ing va lues stored in sectio n i n itializ atio n tab l es (dtbl and btb l ) d e scri b e d in th e file db sct.c. after t h e ex ec u tio n, write-back op e ration of the cache to guarantee t h e c o herency betwee n the cach e m e m o ry and t h e l a rge - capacity internal ram. 3.2.6 cac he settin g (enable) setting cac he c ont rol register 1 validates th e instruction cac he a n d the operand cache .. 3.2.7 vector bas e regis t er (v br) se tting th e v ector tab l e of ex ception a l o p e ration o f t h e ap p licatio n p r og ram is set in vbr.
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 17 of 58 feb 16, 2012 3.2.8 gener a ting the applica t ion program trans f er info rmation (a pp info) tabl e 8 descri bes a b out t h e s t ruct u r e to ge n e rat e t h e tr a n s f er i n fo rm at i on (ap p i n fo ) of appl i cat i on pr o g r a m . the begi nni ng an d t h e en d a d dres s o f t h e ap pl i cat i on pr o g ram i s o b t a i n ed by se ct i on a d d r ess o p erat ors ( sect o p , sece nd ). the following structure is all o cated i n secti o n dappinfo. t h e start a d dress of t h e a ppli cation program (program area, co nstan t area, an d in itialized d ata area) sho u ld b e reg istered in th e app _ t op , and th e end ad dress of th e ap p licatio n p r og r a m in th e ap p_ en d. table 8 ap plication pro gram trans f er informa t ion (appinfo) item description file name appinfo. c structu r e na me appinfo member name value description void *app _top _se c top ("da ppinfo") start address of the application program structure member void *app _en d _se c e nd ("p c ache") end add re ss of the applica t ion pro g ra m +1 the section to place dappinfo note: t h e am ount of size of the loa d e r prog ram (8 kb) and application program m u st no t exceed the ca pacity of the serial fla s h m e m o ry.
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 18 of 58 feb 16, 2012 beginn ing section da pp in fo section end sect ion section pcache uninitialize d area ( section b ) section xxx_1 stack area ( section s ) ? ? ? pr ogr am ar ea i n t he a ppl ic ati on pr ogr am , co nst an t are a , i ni ti ali ze d da ta ar ea ar e the t ar get s to be co ntr ol led b y tra ns fe r i nf orm at io n by th e app li ca tio n pr ogr am . u ni nit ia liz ed a rea (s ect io n b ) s ho uld b e a ll oc ate d in a ra ndo m ar ea . __ sectop(" dappinfo ") __ secend(" pcache") st ar t add re ss of t he ap pl ica ti on pr og ram program area, constant area, initialized data area) app_top app_end a pp lic at ion p ro gra m t ran sf er in fo rm ati on ( ap pin fo ) second section dv ec t t bl section memory map sec tion xxx _2 sec tion xxx _n s ta ck ar ea ( sec ti on s ) sho ul d b e all oc ate d in a ra nd om ar ea . end a dd res s of th e app li ca tio n pro gr am pr o gr am ar ea , co ns ta n t ar e a , i ni ti a li ze d d at a ar e a ) figure 9 genera tion image of tran sfer in forma t ion (appinfo) o f applica t ion program
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 19 of 58 feb 16, 2012 3.3 dow nloader example thi s sect i o n de scri bes t h e d o w nl oade r i n t h i s ap pl i cat i on. 3.3.1 opera t ion o v er v i e w b e fo re e x ecut i ng d o w nl oade r , t h e d o w n l o a d er a n d t h e l o ad er pr og ram sho u l d be t r ans f er r e d fr om t h e de vel o pm ent envi ro nm ent t o t h e hi g h -s pee d i n t e r n al r a m on syst em , an d th e ap p lication p r og ram to th e larg e-cap aci ty intern al r a m by usi n g t h e deb u gge r. fig ur e 10 sh ow s an op er atio n im age of the downloa d e r . the a p plication program is allocated in spi m u lti i/o bus s p ace a r ea, but the debu gge r ca nnot tra n s f er program s to spi m u lti i/o bus s p ace. so only the debug information of a b s file in the spi m u lti i/o bus a r ea while m o t file is d o wn lo ad ed in th e larg e-cap a city ram. ser ial flash mem ory h ' 00 00 000 0 h ' 0 000 1 f ff development e nvir onme nt appl icat ion program *.abs file loader prog ram *. ab s fil e do wnlo ader *.abs file h igh -s peed int erna l ra m h ' fff 8 000 0 h ' fff8 1fff loader pr ogram dow nloa der h ' fff 8 2 000 h ' fff8 3fff appl icat ion program h ' 0000 2000 large-ca paci ty i nter nal r am debug informa tion of appl icati on p rogr am * spi mu lt i i / o bu s sp ace application progr am *. m o t f ile no te : when debug is not necessary, downloading is not necessary . debug informati on on ly h' 1 c 0 0 2 0 0 0 h ' 180 0 2 000 downlo ad wi th off set + h ' 0 400 000 0 figure 10 downl oade r o pera t ion image (1 )
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 20 of 58 feb 16, 2012 th e l o ad er p r og ram an d th e ap p licatio n pro g ram are written in t h e serial fl ash m e m o ry by ex ecu ting down l o ad e r. th e d o wn lo ad er writes th e lo ad er p r og ram fro m h'0 0 0 0 000 0 to h' 00 00 1 fff ad dres s i n t h e se rial flash m e m o ry, and the ap p licatio n prog r a m f r o m h ' 0 0 0 0 20 00 . fi gu re 1 1 s h o w s a n ot her o p e r at i o n i m age of t h e do w n l o a d e r . se rial fla sh m emor y h ' 00 00 0000 h' 0000 1fff development environment application program *.abs file loader program *.abs file downloader *.abs file high - s peed int erna l ra m h ' fff 8 0000 h' fff8 1fff loader program d ownl oade r h ' fff 8 2000 h' fff8 3fff appl icat ion prog ram h' 0000 2000 l arge capa city int erna l ra m d ebug inf orma tion of the application program * sp i multi i / o bus space app lica tion pro gram *. mot fil e note : when deb ug i s no t ne cess ary , down load ing is n ot n eces sary . h' 1800 2000 loader program application program h ' 1 c 00 200 0 figure 11 do w nl oade r o pera t ion image 3.3.2 are as used b y the do w n loader the downloa d er occupies the addres ses from h ' fff8 2000 to h' fff 8 3fff. whe n the loade r progra m , application pr o g ram and d o w n l o a d e r occ upy t h e sam e sect i on, t h e pr o g ram s do n o t o p erat e pr o p erl y . 3.3.3 flow chart figure 12 show s t h e f l o w char t of th e dow nlo a d e r . ex ecu tin g th e downloader place d in the hi g h -s pee d i n t e r n al r a m en ab les writin g in th e serial flash m e m o ry. fo r m o re in fo rm atio n , refer t o t h e section s 3. 3 . 4 t o 3. 3. 8.
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 21 of 58 feb 16, 2012 figure 12 do w n lo ader flo w char t write ok? write ok? end in _ halt end in _error no no ye s start mask the interrupt initialize multi i/ bus controller (spibsc) set stack pointer (r15) re fer to 3 .3. 4 . >" rele ase ser ial flas h m emor y so ftw are prot ect write the loader program write application program yes set the serial flash memory software protect re fer to 3 .3. 6 re fer to 3 .3. 6 re fer to 3 .3. 5 re fer to 3 .3. 7 and fig u re 14 refe r to 3 . 3 . 8 a nd f i gur e 1 5
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 22 of 58 feb 16, 2012 fig u re 13 sh ows t h e fl o w chart of writing t h e lo ad er p r o gra m an d app licatio n p r og ram . figure 13 flo w char t of writing set the write destination address sector erased ? yes no write ok erase the target sector. write by sectors (program command) set the write size update the write destination address update the write size write size is 0 ? yes no calculate the target sector number from the write address verify data (examine writing) verify ok ? yes no write error writ e the loader program write the application program ? erase the target sector befor e writing . when th e sector is not erased , erase it by the sector er ase command ( h d 8) by the unit of 64 kb ? iss u e the page prog r a mm i ng c o mmand (h 02 ) or th e qu ad page programmin g c o m m an d (h 32 ) to write data by 1 b y te. ? to veri fy that the writing i s completed success fully , read the data in th e serial flash memory and compare them with the provided data .
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 23 of 58 feb 16, 2012 3.3.4 stack pointe r setting h?ff8 4 000 is allo cated in the nu m b er in t h e stack po in ter(r15 ) . th is p r o cessing shou ld b e a llocated at the address h' fff8 2000, and use the ass e m b ly langua ge to a voi d the dow n loa d er usi n g the unde fined stac k poi nter. c ca n be use d after co nfigu r i n g th e stack poin ter. th en , t h e do wn lo ad er j u m p s to th e en try fun c tion o f t h e d o wn lo ad er. 3.3.5 interrup t ma sk b'1 1 1 1 is sp eci fied i n th e in terrup t m a sk lev e l b it of th e st atus re gister (sr) as t h e do wnlo ader d o e s no t supp or t th e i n t e rr upt i n a n ope rat i o n. 3.3.6 initializ ation the following initial setting should be gi ven to the serial flash m e m o ry be fore accessi ng. 1. configure sp ibsc 2. issu e th e write en ab le co mman d to t h e serial fl ash m e m o ry to ca ncel the s o ft ware protect ion. 3.3.7 writing th e l oader progr am the downloa d er rea d s the l o a d er program that has bee n tra n sfe rre d at t h e address from h' fff8 0000 to h' fff8 1ff f in the hi gh-s peed internal r a m, and write s the l o ade r program at the address fr om h' 0000 0000 to h' 0000 1fff i n the serial flash m e m o ry . tab l e 9 lists th e lo ad er p r og ram writing . table 9 loader program writing item description load er p r og ram tran sfer s ource a ddress (hi gh-sp eed internal ram) h'fff 8 000 0 (fixed) loader p r og ram tran sfer d estinatio n ad dre s s (seri al flash mem ory ) h'0 000 0 000 (fixed) tran sfer size h'2000 (fixed) writin g pro c e dures 1. che c k if the destinatio n ad dre s s ha s already been e r a s e d 2. erase the dat a whe n the a ddress ha s n ot been e r as ed 3. issue the program command to write
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 24 of 58 feb 16, 2012 3.3.8 writing th e applica t ion program th e do wn lo ader writes th e app licatio n p r og ra m fro m th e add r ess h'0 0 0 0 20 00 i n th e large-cap acity in tern al r a m. tab l e 1 0 lists th e ap p licatio n p r og ram writing . table 10 application pr ogram writi ng item description application program tran sf er source a dd r e ss (l arge- c a pac i ty internal ram) h?1 c 00 2 000 (do w nl oad a d dre s s in mot file) application program tran sf er de stinatio n address (s erial fla s h memo ry ) h'0000 2000 (fixed) transfer size extracts from t he appinfo in the application program (depends on the application program) writin g pro c e dures 1. che c k if the destinat io n ad dre s s ha s already been e r a s e d 2. erase the dat a whe n the a ddress ha s n o t been e r as ed 3. issue the program command to write.
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 25 of 58 feb 16, 2012 ? exe cut e t he do wnl oad er start reset cpu set the frequency control register (frqcr) transfer programs to ram insert a software brea kpoint at the _halt in se rt a s oft wa re bre ak poi nt to st op the pr og ram wh en th e d own lo ade r t erm in ate s . ? _h alt is a fu nct ion in t he dow nl oad er whi ch is ca lle d w he n t he do wnl oad er en ds suc ces sf ull y . ? _err or is a fun cti on in th e d ow nlo ade r whi ch i s c al led wh en th e d own lo ade r e nds i n a n e rro r . execute downloader wait until the downloader is completed remove the software breakpoint at the _halt end ? wh en the do wn loa der te rm ina tes , r em ove th e sof tw are br ea kpo int to r eco ver th e ori gin al env ir onm ent . tr an sfe r t he lo ade r p ro gra m a nd do wnl oad er to th e hig h -s pee d i nt ern al ram , an d t he ap pli cat ion pr og ram to th e lar ge - c apa kci ty in ter nal ra m . remove the software brea kpoint at the _error insert a software breakpoint at the _error set system control register 5 (syscr5) ? w rit e - e nab le in th e l ar ge -ca pa cit y i nte rn al ram ? ? 3.3.9 ba tch file b e fo re e x ecut i ng t h e d o w n l o ader , th e l o a d e r pr og ram and t h e do w nl oade r m u st be t r a n s f er red t o t h e hi gh -s peed i n t e r n al ram, an d th e ap p licatio n prog ram m u st b e t r an sferred to th e larg e-cap acit y in tern al r a m to write th e lo ad er p r o g ram and the a p plication program in the serial flash m e m o ry . thi s a ppl i cat i o n not e uses t h e com m and bat c h fi l e i n t h e hi gh - p er fo rm ance em bedde d wo r k sh o p t o e x ecut e a seri es of pr ocessi ng aut o m a ti cal ly t h o u g h m a nual pr ocess p o ssi bl e. fi gu re 1 4 s h o w s t h e fl ow ch art o f t h e com m and bat c h fi l e . t h e c o m m a nd bat c h fi l e i s use d t o t r a n sfe r pr og ram s t o t h e h igh -sp e ed in tern al r a m an d th e larg e-cap a city in tern al ra m , an d write p r o g ram s in the serial flash m e m o ry . figure 14 command ba tch file flo w char t
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 26 of 58 feb 16, 2012 4. sample program listing 4.1 loader pr ogram 4.1.1 loader pro gram listing ?loader.src? (1) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 ;/****************************************************************************** ;* disclaimer ;* ;* this software is supplied by renesas electronics corporation and is only ;* intended for use with renesas products. no other uses are authorized. ;* ;* this software is owned by renesas electronics corporation and is protected under ;* all applicable laws, including copyright laws. ;* ;* this software is provided "as is" and renesas makes no warranties ;* regarding this software, whether express, implied or statutory, ;* including but not limited to warranties of merchantability, fitness for a ;* particular purpose and non-infringement. all such warranties are expressly ;* disclaimed. ;* ;* to the maximum extent permitted not prohibited by law, neither renesas ;* electronics corporation nor any of its affiliated companies shall be liable ;* for any direct, indirect, special, incidental or consequential damages ;* for any reason related to this software, even if renesas or its ;* affiliates have been advised of the possibility of such damages. ;* ;* renesas reserves the right, without notice, to make changes to this ;* software and to discontinue the availability of this software. ;* by using this software, you agree to the additional terms and ;* conditions found by accessing the following link: ;* http://www.renesas.com/disclaimer ;******************************************************************************** ;* copyright (c) 2011 renesas electronics corporation. all rights reserved. ;**************************** technical reference data ************************** ;* system name : SH7268/sh7269 firm update sample program ;* file name : ld_loader.src ;* abstract : loader program preprocessing/jump processing to the application ;* : program ;* version : 1.00.00 ;* device : SH7268/sh7269 ;* tool-chain : high-performance embedded workshop (ver.4.07.00). ;* : c/c++ compiler package for the superh risc engine family ;* : (ver.9.03release02). ;* os : none ;* h/w platform: r0k57269(cpu board) ;* description : ;******************************************************************************** ;* history : jul.06,2011 ver.1.00.00 ;*""file comment end""**********************************************************/ .section loader_entry,code,align = 4 .import _main .export _jmp_app_prog
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 27 of 58 feb 16, 2012 4.1.2 loader pro gram listing "loader.src" (2) 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 _loader_prog: mov.l l2,r15 ; sets the stack pointer mov.l l1,r0 ; retrieves the entry function of the loader program jmp @r0 ; jumps to the entry function of the loader program nop ;/*""func comment""************************************************************** ; * id : ; * outline : jump to the application program ; *------------------------------------------------------------------------------ ; * include : ; *------------------------------------------------------------------------------ ; * declaration : _jmp_app_prog ; *------------------------------------------------------------------------------ ; * description : 1. retrieves the stack pointer value stored in the first 12 to ; * : 15 bytes in the application program. ; * : 2. specifies the stack pointer (r15). ; * : 3. retrieves the entry function address stored in the first 8 to ; * : 11 bytes in the application program. ; * : 4. jumps to the entry function. ; *------------------------------------------------------------------------------ ; * argument : r4 ; i : start address of the application program ; *------------------------------------------------------------------------------ ; * return value: none ; *""func comment end""**********************************************************/ _jmp_app_prog: mov.l r4,r0 ; substitutes the start address of the application program for r0 add #12,r0 ; calculates the address storing the stack pointer value and ; substitutes the address for r0 mov.l @r0,r15 ; sets the stack pointer mov.l r4,r0 ; substitutes the start address of the application program for r0 add #8,r0 ; calculates the address storing the entry function of the application ; program and substitutes the address for r0 mov.l @r0,r0 ; substitutes the entry function address of the application ; program for r0 jmp @r0 ; jumps to the entry function of the application program nop .align 4 l1: .data.l _main ; entry function address of the loader program l2: .data.l h'fff82000 ; stack pointer (r15) value of the loader program .pool .end ;/* end of file */
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 28 of 58 feb 16, 2012 4.1.3 loader pro gram listing "ld_main.c" (1) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 /****************************************************************************** * disclaimer * * this software is supplied by renesas electronics corporation and is only * intended for use with renesas products. no other uses are authorized. * * this software is owned by renesas electronics corporation and is protected under * all applicable laws, including copyright laws. * * this software is provided "as is" and renesas makes no warranties * regarding this software, whether express, implied or statutory, * including but not limited to warranties of merchantability, fitness for a * particular purpose and non-infringement. all such warranties are expressly * disclaimed. * * to the maximum extent permitted not prohibited by law, neither renesas * electronics corporation nor any of its affiliated companies shall be liable * for any direct, indirect, special, incidental or consequential damages * for any reason related to this software, even if renesas or its * affiliates have been advised of the possibility of such damages. * * renesas reserves the right, without notice, to make changes to this * software and to discontinue the availability of this software. * by using this software, you agree to the additional terms and * conditions found by accessing the following link: * http://www.renesas.com/disclaimer ******************************************************************************** * copyright (c) 2011 renesas electronics corporation. all rights reserved. **************************** technical reference data ************************** * system name : SH7268/sh7269 firm update sample program * file name : ld_main.c * abstract : loader main * version : 1.00.00 * device : SH7268/sh7269 * tool-chain : high-performance embedded workshop (ver.4.07.00). * : c/c++ compiler package for the superh risc engine family * : (ver.9.03 release02). * os : none * h/w platform: r0k57269(cpu board) * description : ******************************************************************************** * history : jul.06,2011 ver.1.00.00 *******************************************************************************/ #include #include #include #include "iodefine.h" #include "serial_flash.h"
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 29 of 58 feb 16, 2012 4.1.4 loader pro gram listing "ld_main.c" (2) 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 /* ==== macro defined ==== */ #define fpscr_init 0x00040001 /* value to set in the fpscr register */ #define int_mask 0x000000f0 /* value to set in the sr register (for masking the interrupt) */ #define aprog_top_sflash 0x00002000 /* start address of the application program */ /* (serial flash memory) */ #define appinfo_top aprog_top_sflash /* address the appinfo.app_top is located */ #define appinfo_end (aprog_top_sflash + 4) /* address the appinfo.app_end is located */ /* ==== prototype declaration ==== */ void main(void); void get_appinfo( unsigned long *app_top_addr,unsigned long *app_end_addr); void app_prog_transfer(unsigned long app_top_addr,unsigned long app_end_addr); void system_down(void); extern void jmp_app_prog(unsigned long app_top_addr); extern void io_set_cpg(void); extern void sf_byte_read_long(unsigned long addr, unsigned long *buf, int size); /* ==== external data ==== */ extern unsigned long dummy_vectors;
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 30 of 58 feb 16, 2012 4.1.5 loader pro gram listing "ld_main.c" (3) 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 /******************************************************************************* * id : * outline : loader program main * include : #include "serial_flash.h" * declaration : void main(void); * description : refers the data in the appinfo to transfer the application program * : to the large-capacity internal ram, and jumps to the entry function * : of the application program. * argument : void * return value: void ******************************************************************************/ void main(void) { unsigned long app_top,app_end; /* sets the fpscr */ set_fpscr(fpscr_init); /* sets the tentative vbr */ set_vbr((void *)(&dummy_vectors)); /* masks the interrupt */ set_cr(int_mask); /* sets the cpg */ io_set_cpg(); /* sets the spibsc */ sf_init_serial_flash_spibsc(); /* retrieves the appinfo */ get_appinfo(&app_top,&app_end); sf_allocate_exspace_spibsc(); /* jumps to the application program */ jmp_app_prog(app_top); while(1){ /* loop */ } }
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 31 of 58 feb 16, 2012 4.1.6 loader pro gram listing "ld_main.c" (4) 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 /******************************************************************************* * id : * outline : retrieve the appinfo * include : #include "serial_flash.h" * declaration : void get_appinfo (unsigned long *app_top_addr, * : unsigned long *app_end_addr); * description : retrieves the appinfo. * : retrieves the appinfo.top from h'2000 to h'2003 in serial flash * : memory, and stores it in the address specified by the first * : argument. this function also retrieves the appinfo.end from * : h'2004 to h'2007 in serial flash memory, and stores it in the * : address specified by the second argument. * argument : unsigned long app_top_addr ; o : start address of the application * : program at destination * : unsigned long app_end_addr ; o : end address of the application * : program at destination * return value: void ******************************************************************************/ void get_appinfo( unsigned long *app_top_addr,unsigned long *app_end_addr) { /* retrieves the appinfo.top */ sf_byte_read_spibsc(appinfo_top, (unsigned char *)app_top_addr, 4); /* retrieves the appinfo.end */ sf_byte_read_spibsc(appinfo_end, (unsigned char *)app_end_addr, 4); }
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 32 of 58 feb 16, 2012 4.1.7 loader pro gram listing "ld_main.c" (5) 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 /******************************************************************************* * id : * outline : transfer the application program * include : #include "serial_flash.h" * declaration : void app_prog_transfer(unsigned long app_top_addr, * : unsigned long app_end_addr); * description : calculates the size of the application program, and transfers * : the application program from serial flash memory to the * : large-capacity internal ram. (rounds up the allocation size of the * : application program to multiples of 4 to transfer in longword.) * argument : unsigned long app_top_addr ; i : start address of the application * : program at destination * : unsigned long app_end_addr ; i : end address of the application * : at destination * return value: void ******************************************************************************/ void app_prog_transfer(unsigned long app_top_addr,unsigned long app_end_addr) { unsigned long app_prog_size; /* calculates the size of the application program */ app_prog_size = app_end_addr - app_top_addr; if( ( app_prog_size & 0x00000003 ) != 0 ){ app_prog_size &= 0xfffffffc; app_prog_size += 4; /* rounds up the allocation size of the application program to multiples of 4. */ } /* loads the application program in the large-capacity internal ram */ sf_byte_read_spibsc(aprog_top_sflash, (unsigned char *)app_top_addr, app_prog_size); } /******************************************************************************* * id : * outline : terminate the system * include : * declaration : void system_down(void); * description : this function contains the infinite loop. * : as this is registered in the dummy_vectors table, this is * : called when an exception occurs while the loader program * : is operating. * argument : void * return value: void ******************************************************************************/ void system_down(void) { while(1){ /* system error */ } } /* end of file */
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 33 of 58 feb 16, 2012 4.2 application program 4.2.1 application program li sting ?main .c?(1) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 /****************************************************************************** * disclaimer * * this software is supplied by renesas electronics corporation and is only * intended for use with renesas products. no other uses are authorized. * * this software is owned by renesas electronics corporation and is protected under * all applicable laws, including copyright laws. * * this software is provided "as is" and renesas makes no warranties * regarding this software, whether express, implied or statutory, * including but not limited to warranties of merchantability, fitness for a * particular purpose and non-infringement. all such warranties are expressly * disclaimed. * * to the maximum extent permitted not prohibited by law, neither renesas * electronics corporation nor any of its affiliated companies shall be liable * for any direct, indirect, special, incidental or consequential damages * for any reason related to this software, even if renesas or its * affiliates have been advised of the possibility of such damages. * * renesas reserves the right, without notice, to make changes to this * software and to discontinue the availability of this software. * by using this software, you agree to the additional terms and * conditions found by accessing the following link: * http://www.renesas.com/disclaimer ******************************************************************************** * copyright (c) 2011 renesas electronics corporation. all rights reserved. **************************** technical reference data ************************** * system name : SH7268/sh7269 sample program * file name : main.c * abstract : sample program main * version : 1.00.00 * device : SH7268/sh7269 * tool-chain : high-performance embedded workshop (ver.4.07.00). * : c/c++ compiler package for the superh risc engine family * : (ver.9.03release02). * os : none * h/w platform: r0k57269(cpu board) * description : ******************************************************************************** * history : jul.06,2011 ver.1.00.00 *******************************************************************************/ #include #include #include #include "iodefine.h" #include "r0k57269.h"
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 34 of 58 feb 16, 2012 4.2.2 application program li sting ?main .c? (2) 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 /* ==== prototype declaration ==== */ void main(void); void io_init_cmt0(void); void int_cmt_cmi0(void); /* ==== global variable ==== */ int g_led_onoff; /* led lighting/turning off */ /******************************************************************************* * id : * outline : main *------------------------------------------------------------------------------ * include : *------------------------------------------------------------------------------ * declaration : void main(void); *------------------------------------------------------------------------------ * description : *------------------------------------------------------------------------------ * argument : void *------------------------------------------------------------------------------ * return value: void *------------------------------------------------------------------------------ * note : none ******************************************************************************/ void main(void) { puts("\nsh7269 cpu board sample program. ver.0.02.00"); puts("copyright (c) 2010(2011) renesas electronics corporation. all rights eserved."); puts("\n"); /* ==== initial led port ==== */ g_led_onoff = 1; led_init(); /* led initialization */ /* ==== start timer ==== */ io_init_cmt0(); /* cmt initialization */ /* ==== setting of interrupt priority level ==== */ intc.ipr12.bit._cmt0 = 0x1; /* cmi priority level of interrupt = 1 */ while(1){ /* loop */ } }
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 35 of 58 feb 16, 2012 4.2.3 application program li sting ?main .c?(3) 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 /******************************************************************************* * id : * outline : cmt0 setting *------------------------------------------------------------------------------ * include : #include "iodefine.h" *------------------------------------------------------------------------------ * declaration : void io_init_cmt0(void) ; *------------------------------------------------------------------------------ * description : cmt0 is set as a fixed cycle of about 500ms timer. *------------------------------------------------------------------------------ * argument : void *------------------------------------------------------------------------------ * return value: void *------------------------------------------------------------------------------ * note : none ******************************************************************************/ void io_init_cmt0(void) { /* ---- stbcr7 setting ---- */ cpg.stbcr7.bit.mstp72 = 0; /* module standby clear */ /* ==== cmt0 setting ==== */ /* ---- cmstr setting ---- */ cmt.cmstr.bit.str0 = 0; /* count stop */ /* ---- cmcsr0 setting ---- */ cmt.cmcsr0.word = 0x0043; /* pclock/512 */ /* ---- cmcnt0 setting ---- */ cmt.cmcnt0.word = 0x0000; /* timer counter clear */ /* ---- cmcor0 setting ---- */ cmt.cmcor0.word = 0x7f08/5; /* 500/5=100ms */ /* ---- cmstr setting ---- */ cmt.cmstr.bit.str0 = 0x1; /* count start */ }
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 36 of 58 feb 16, 2012 4.2.4 application program li sting ?main .c?(4) 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 /******************************************************************************* * id : * outline : cmi interrupt *------------------------------------------------------------------------------ * include : #include "iodefine.h" *------------------------------------------------------------------------------ * declaration : void int_cmt_cmi0(void); *------------------------------------------------------------------------------ * description : the cmf flag is cleared, and the output of * : led of each 0.5sec is reversed. *------------------------------------------------------------------------------ * argument : void *------------------------------------------------------------------------------ * return value: void *------------------------------------------------------------------------------ * note : none ******************************************************************************/ void int_cmt_cmi0(void) { /* ====cmf clearness of flag ==== */ cmt.cmcsr0.bit.cmf = 0; /* ==== port reversing output(led blinking) ==== */ g_led_onoff ^= 1; if(g_led_onoff == 0){ led_on(id_led1); led_on(id_led2); } else{ led_off(id_led1); led_off(id_led2); } } /* end of file */
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 37 of 58 feb 16, 2012 4.2.5 application program li sting ?appi nfo.c?(1) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 /****************************************************************************** * disclaimer * * this software is supplied by renesas electronics corporation and is only * intended for use with renesas products. no other uses are authorized. * * this software is owned by renesas electronics corporation and is protected under * all applicable laws, including copyright laws. * * this software is provided "as is" and renesas makes no warranties * regarding this software, whether express, implied or statutory, * including but not limited to warranties of merchantability, fitness for a * particular purpose and non-infringement. all such warranties are expressly * disclaimed. * * to the maximum extent permitted not prohibited by law, neither renesas * electronics corporation nor any of its affiliated companies shall be liable * for any direct, indirect, special, incidental or consequential damages * for any reason related to this software, even if renesas or its * affiliates have been advised of the possibility of such damages. * * renesas reserves the right, without notice, to make changes to this * software and to discontinue the availability of this software. * by using this software, you agree to the additional terms and * conditions found by accessing the following link: * http://www.renesas.com/disclaimer ******************************************************************************** * copyright (c) 2011 renesas electronics corporation. all rights reserved. **************************** technical reference data ************************** * system name : SH7268/sh7269 sample program * file name : appinfo.c * abstract : generate the application program transfer information (appinfo). * version : 1.00.00 * device : SH7268/sh7269 * tool-chain : high-performance embedded workshop (ver.4.07.00). * : c/c++ compiler package for the superh risc engine family * : (ver.9.03 release02). * os : none * h/w platform: r0k57269(cpu board) * description : ******************************************************************************** * history : jul.06,2011 ver.1.00.00 *******************************************************************************/
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 38 of 58 feb 16, 2012 4.2.6 application program li sting ?appi nfo.c?(2) 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 #include "appinfo.h" #pragma section appinfo static appinfo appinfo = { __sectop("dappinfo"), /* start address in the start section of the application */ /* program (program area, constant area, and initialized */ /* data area). */ __secend("pcache") /* end address in the end section of the application */ /* program (program area, constant area, and initialized */ /* data area) */ }; /* end of file */
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 39 of 58 feb 16, 2012 4.2.7 application program li sting ?appi nfo.h? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 /****************************************************************************** * disclaimer * * this software is supplied by renesas electronics corporation and is only * intended for use with renesas products. no other uses are authorized. * * this software is owned by renesas electronics corporation and is protected under * all applicable laws, including copyright laws. * * this software is provided "as is" and renesas makes no warranties * regarding this software, whether express, implied or statutory, * including but not limited to warranties of merchantability, fitness for a * particular purpose and non-infringement. all such warranties are expressly * disclaimed. * * to the maximum extent permitted not prohibited by law, neither renesas * electronics corporation nor any of its affiliated companies shall be liable * for any direct, indirect, special, incidental or consequential damages * for any reason related to this software, even if renesas or its * affiliates have been advised of the possibility of such damages. * * renesas reserves the right, without notice, to make changes to this * software and to discontinue the availability of this software. * by using this software, you agree to the additional terms and * conditions found by accessing the following link: * http://www.renesas.com/disclaimer ******************************************************************************** * copyright (c) 2011 renesas electronics corporation. all rights reserved. **************************** technical reference data ************************** * system name : SH7268/sh7269 sample program * file name : appinfo.h * abstract : header file of the application program transfer information (appinfo). * version : 1.00.00 * device : SH7268/sh7269 * tool-chain : high-performance embedded workshop (ver.4.07.00). * : c/c++ compiler package for the superh risc engine family * : (ver.9.03 release02). * os : none * h/w platform: r0k57269(cpu board) * description : ******************************************************************************** * history : jul.06,2011 ver.1.00.00 *******************************************************************************/ #ifndef __appinfo_h__ #define __appinfo_h__ typedef struct appinfo_t { void *app_top; /* start address of the application program */ void *app_end; /* end address of the application program */ } appinfo; #endif /* __appinfo_h__ */ /* end of file */
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 40 of 58 feb 16, 2012 4.3 dow nloader 4.3.1 dow nloade r program listing ?dow nload er.hdc? (1) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 #/****************************************************************************** #* disclaimer #* #* this software is supplied by renesas electronics corporation and is only #* intended for use with renesas products. no other uses are authorized. #* #* this software is owned by renesas electronics corporation and is protected under #* all applicable laws, including copyright laws. #* #* this software is provided "as is" and renesas makes no warranties #* regarding this software, whether express, implied or statutory, #* including but not limited to warranties of merchantability, fitness for a #* particular purpose and non-infringement. all such warranties are expressly #* disclaimed. #* #* to the maximum extent permitted not prohibited by law, neither renesas #* electronics corporation nor any of its affiliated companies shall be liable #* for any direct, indirect, special, incidental or consequential damages #* for any reason related to this software, even if renesas or its #* affiliates have been advised of the possibility of such damages. #* #* renesas reserves the right, without notice, to make changes to this #* software and to discontinue the availability of this software. #* by using this software, you agree to the additional terms and #* conditions found by accessing the following link: #* http://www.renesas.com/disclaimer #******************************************************************************** #* copyright (c) 2011 renesas electronics corporation. all rights reserved. #**************************** technical reference data ************************** #* system name : SH7268/sh7269 firm update sample program #* file name : downloader.hdc #* abstract : ` ? #* version : 1.00.00 #* device : sh7269/sh7269 #* tool-chain : high-performance embedded workshop (ver.4.07.00). #* : c/c++ compiler package for the superh risc engine family #* : (ver.9.03release02). #* os : none #* h/w platform: r0k57269(cpu board) #* description : #******************************************************************************** #* history : jul.06,2011 ver.1.00.00 #*""file comment end""**********************************************************/ tcl enable
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 41 of 58 feb 16, 2012 4.3.2 do w n lo ader program lis t ing ?do w nl o a der.hdc ? (2 ) 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 #macro downloader -start proc init_hardware {} { # set cpg mf h'fffe0010 h'fffe0011 h'1015 word # set syscr5 mf h'fffe0428 h'fffe0428 h'0f byte } proc downloader {} { # reset cpu reset # init_hardware call routines init_hardware #download all [download modules] in high-performance embedded workshop file_load_all #permit user stack to us e software breakpoint sh2a_sbstk enable # set software break point in _halt(refer to main.c) set_disassembly_soft_break _halt set # set software break point in _error(refer to main.c) set_disassembly_soft_break _error set # execute _downloader(refer to downloader.src). wait till stops go wait _downloader # clear software break point set in _halt set_disassembly_soft_break _halt clear # clear the software break point set in _error set_disassembly_soft_break _error clear } downloader #macro downloader -end #note: "tcl","reset","file_load","sh2a_sbstk","set_disassembly_soft_break","go" are the commands of #high-performance embedded workshop and e10a-usb emulator. for the details of commands, see the manual. # /* end of file */
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 42 of 58 feb 16, 2012 4.3.3 dow nloade r program listing ?dl_ entry .src? (1) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 ;/****************************************************************************** ;* disclaimer ;* ;* this software is supplied by renesas electronics corporation and is only ;* intended for use with renesas products. no other uses are authorized. ;* ;* this software is owned by renesas electronics corporation and is protected under ;* all applicable laws, including copyright laws. ;* ;* this software is provided "as is" and renesas makes no warranties ;* regarding this software, whether express, implied or statutory, ;* including but not limited to warranties of merchantability, fitness for a ;* particular purpose and non-infringement. all such warranties are expressly ;* disclaimed. ;* ;* to the maximum extent permitted not prohibited by law, neither renesas ;* electronics corporation nor any of its affiliated companies shall be liable ;* for any direct, indirect, special, incidental or consequential damages ;* for any reason related to this software, even if renesas or its ;* affiliates have been advised of the possibility of such damages. ;* ;* renesas reserves the right, without notice, to make changes to this ;* software and to discontinue the availability of this software. ;* by using this software, you agree to the additional terms and ;* conditions found by accessing the following link: ;* http://www.renesas.com/disclaimer ;******************************************************************************** ;* copyright (c) 2010(2011) renesas electronics corporation. all rights reserved. ;**************************** technical reference data ************************** ;* system name : SH7268/sh7269 firm update sample program ;* file name : dl_entry.src ;* abstract : downloader start up ;* version : 0.03.00 ;* device : SH7268/sh7269 ;* tool-chain : high-performance embedded workshop (ver.4.07.00). ;* : c/c++ compiler package for the superh risc engine family ;* : (ver.9.03release02). ;* os : none ;* h/w platform: r0k57269(cpu board) ;* description : ;******************************************************************************** ;* history : sep.06,2010 ver.0.01.00 ;* : apr.27,2011 ver.0.02.00 change comment ;* : may.08,2011 ver.0.03.00 change comment ;*""file comment end""**********************************************************/
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 43 of 58 feb 16, 2012 4.3.4 dow nloade r program listing ?dl_ entry .src? (2) 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 .section entry,code,align = 4 .import _poweron_reset_pc _downloader: mov.l stack_pointer,r15 ; setting stack pointer mov.l main_program,r0 ; get entry address of downloader jmp @r0 ; jump to entry address of downloader nop .align 4 main_program: .data.l _poweron_reset_pc ; entry address of downloader stack_pointer: .data.l h'fff84000 ; stack pointer of downloader(r15) .pool .end ;/* end of file */
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 44 of 58 feb 16, 2012 4.3.5 dow nloade r program list ?dl_ma in.c? (1) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 /****************************************************************************** * disclaimer * * this software is supplied by renesas electronics corporation and is only * intended for use with renesas products. no other uses are authorized. * * this software is owned by renesas electronics corporation and is protected under * all applicable laws, including copyright laws. * * this software is provided "as is" and renesas makes no warranties * regarding this software, whether express, implied or statutory, * including but not limited to warranties of merchantability, fitness for a * particular purpose and non-infringement. all such warranties are expressly * disclaimed. * * to the maximum extent permitted not prohibited by law, neither renesas * electronics corporation nor any of its affiliated companies shall be liable * for any direct, indirect, special, incidental or consequential damages * for any reason related to this software, even if renesas or its * affiliates have been advised of the possibility of such damages. * * renesas reserves the right, without notice, to make changes to this * software and to discontinue the availability of this software. * by using this software, you agree to the additional terms and * conditions found by accessing the following link: * http://www.renesas.com/disclaimer ******************************************************************************** * copyright (c) 2011 renesas electronics corporation. all rights reserved. **************************** technical reference data ************************** * system name : SH7268/sh7269 firm update sample program * file name : dl_main.c * abstract : downloader main * version : 1.00.00 * device : SH7268/sh7269 * tool-chain : high-performance embedded workshop (ver.4.07.00). * : c/c++ compiler package for the superh risc engine family * : (ver.9.03 release02). * os : none * h/w platform: r0k57269(cpu board) * description : ******************************************************************************** * history : jul.06,2011 ver.1.00.00 *******************************************************************************/ #include #include #include #include "iodefine.h" #include "serial_flash.h"
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 45 of 58 feb 16, 2012 4.3.6 dow nloade r program list ?dl_ma in.c? (2) 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 /* ==== macro defined ==== */ #define sector_size sf_sector_size /* sector size */ #define sector_num sf_num_of_sector /* total number of sectors in the device */ #define device_size (sector_size * sector_num) /* device size */ #if (sflash_dual == 0) #define l_prog_size 8192 /* loader program size */ #else #define l_prog_size 4096 /* loader program size */ #endif #define l_prog_src 0xfff80000 /* source address of the loader program */ #define l_prog_dst 0x00000000 /* destination address of the loader program */ #define aprog_top_sflash 0x00002000 /* start address of the application program */ #define aprog_top_ram 0x1c002000 /* start address of the application program */ /* when changing the start section of the */ /* application program, change this definition */ #define appinfo_top aprog_top_ram /* address the appinfo.app_top is located */ #define appinfo_end ( aprog_top_ram + 4 ) /* address the appinfo.app_end is located */ /* ==== prototype declaration ==== */ /*** user api ****/ void main(void); static void halt(void); static void error(void); static void init_erase_flag(void); static int is_erased_sector(unsigned long sector_no); static void set_erase_flag(unsigned long sector_no); static int write_prog_data(unsigned char *program_data, unsigned long sflash_addr, unsigned long size); /*** data ***/ static unsigned char sflash_erase_flag[sector_num];/* 0: sector not erased,1: sector erased */
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 46 of 58 feb 16, 2012 4.3.7 dow nloade r program list ?dl_ma in.c? (3) 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 /******************************************************************************* * id : * outline : downloader main * include : * declaration : void main(void); * description : writes the loader program and application program in serial * : flash memory as the following procedures. * : 1. mask the interrupt while the downloader is operating. * : 2. initialize the rspi0. * : 3. disable the software protection in serial flash memory. * : 4. write the loader program in serial flash memory. * : 5. write the application program in serial flash memory. * argument : void * return value: void ******************************************************************************/ void main(void) { unsigned long app_top_addr,app_end_addr,app_prog_size; /* initializes the erase flag */ init_erase_flag(); /* initializes the spibsc */ sf_init_serial_flash_spibsc(); /* disables the software protection in serial flash memory */ sf_protect_ctrl_spibsc(sf_req_unprotect); /* writes the loader program */ if( write_prog_data( (unsigned char *)l_prog_src, l_prog_dst, l_prog_size) < 0 ){ error(); } /* retrieves the start address and end address from the application program transfer information (appinfo) */ app_top_addr = *(volatile unsigned long *)appinfo_top; app_end_addr = *(volatile unsigned long *)appinfo_end; /* calculates the size of the application program */ app_prog_size = app_end_addr - app_top_addr;
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 47 of 58 feb 16, 2012 4.3.8 dow nloade r program list ?dl_ma in.c? (4) 128 129 130 131 132 133 134 135 136 137 138 139 /* writes the application program */ if( write_prog_data((unsigned char *)aprog_top_ram,aprog_top_sflash, app_prog_size)<0){ error(); } /* enables the software protection in serial flash memory */ sf_protect_ctrl_spibsc(sf_req_protect); /* exits the downloader */ halt(); }
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 48 of 58 feb 16, 2012 4.3.9 do w n lo ader program lis t ?dl_main.c ? (5 ) 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 /******************************************************************************* * id : * outline : write the program data * include : * declaration : int write_prog_data(unsigned char *program_data, * : unsigned long sflash_addr, unsigned long size); * description : writes the program data as the following procedures. * : 1. erase the target sector when it is not erased. * : 2. write the program data in serial flash memory. * : 3. reads the data in serial flash memory and compare it with the * : provided data. * argument : unsigned char *program_data ; i : start address of the program data * : unsigned long sflash_addr ; i : start address at the destination in * serial flash memory * : unsigned long size ; i : write size * return value: equal or bigger than 0: success * : less than 0: error ******************************************************************************/ int write_prog_data(unsigned char *program_data, unsigned long sflash_addr, unsigned long size) { unsigned long sector_no; unsigned long saddr; unsigned long sz; unsigned char read_data[2]; unsigned char *w_p; int wr_size; int rd_size; int bsz; bsz = 1; /* ==== copies the value from the argument to the local variable ==== */ saddr = sflash_addr; sz = size; w_p = program_data; /* ==== writes data in serial flash memory ==== */ while( sz > 0){ if(sz > ((256 * bsz) - (saddr % (256 * bsz)))){ wr_size = (int)((256 * bsz) - (saddr % (256 * bsz))); } else{ wr_size = (int)sz; } sector_no = saddr / (sector_size * bsz);
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 49 of 58 feb 16, 2012 4.3.10 dow nloade r program list ?dl_ma in.c? (6) 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 if( is_erased_sector(sector_no) == 0 ){ /* when it is not erased */ sf_sector_erase_spibsc(sector_no); /* erase */ set_erase_flag(sector_no); /* when it is erased, set the erase flag */ } sf_byte_program_spibsc(saddr, w_p, wr_size ); /* writes data in units of */ /* single byte */ w_p += wr_size; saddr += wr_size; sz -= wr_size; } /* ==== verifies data (serial flash memory is programmed successfully) ==== */ saddr = sflash_addr; sz = size; w_p = program_data; rd_size = 1; while( sz > 0){ sf_byte_read_spibsc(saddr,read_data, rd_size); /* reads the data written in */ /* serial flash memory */ if( w_p[0] != read_data[0] ){ return -1; /* returns an error when the data */ /* unmatched */ } w_p += rd_size; saddr += rd_size; sz -= rd_size; } return 0; }
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 50 of 58 feb 16, 2012 4.3.11 dow nloade r program list ?dl_ma in.c? (7) 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 /******************************************************************************* * id : * outline : initialize the erase flag * include : * declaration : static void init_erase_flag(void); * description : initializes the table sflash_erase_flag[]. * argument : void * return value: void ******************************************************************************/ static void init_erase_flag(void) { int i; for( i=0; i < sector_num ;i++){ sflash_erase_flag[i] = 0; } } /******************************************************************************* * id : * outline : retrieve the sector erase status * include : * declaration : static int is_erased_sector(unsigned long sector_no); * description : returns the information (not erased or eraser) of the * : sector specified by the sector number. * argument : unsigned long sector_no ; i : sector number * return value: 1 : sector in the specified address is already erased * : 0 : sector in the specified address is not erased ******************************************************************************/ static int is_erased_sector(unsigned long sector_no) { return sflash_erase_flag[sector_no]; } /******************************************************************************* * id : * outline : set the erase flag * include : * declaration : static void set_erase_flag(unsigned long sector_no); * description : sets the erase flag to modify the information of the specified * : sector as erased. * argument : unsigned long sector_no ; i : sector number * return value: void ******************************************************************************/ static void set_erase_flag(unsigned long sector_no) { sflash_erase_flag[sector_no] = 1; }
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 51 of 58 feb 16, 2012 4.3.12 do w n lo ader program lis t ?dl_main.c ? (8 ) 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 /******************************************************************************* * id : * outline : program stops (successful). * include : * declaration : static void halt(void); * description : when the downloader ends successfully, this function is called * : to stop the program. * argument : void * return value: void ******************************************************************************/ static void halt(void) { while(1){ /* when the downloader ends successfully, this function stops the program. */ } } /******************************************************************************* * id : * outline : program stops (error). * include : * declaration : static void error(void); * description : when the downloader ends in error, this function is called * : to stop the program. * argument : void * return value: void ******************************************************************************/ static void error(void) { while(1){ /* when the downloader ends in error, this function stops the program */ } } /* end of file */
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 52 of 58 feb 16, 2012 5. using the dow nloader th e do wn lo ader in th is ap p l i catio n is d e sign ed to op er ate with th e co m b in atio n of t h e high-pe r form ance em bedded wo r k sh o p a n d t h e e 1 0 a - u sb em ul at or. wh en usi n g t h e do wnl o ade r wi t h ot he r devel o p m ent envi ro nm ent s , al t e r t h e program according to the usa g e e nvi ronm ents. pro g ram s can no t b e written in th e serial flash m e m o ry b y selectin g th e downl o ad e r m o du le in t h e dow n loa d di al og b o x on t h e de bu g m e nu. thi s sec t i on e xpl ai n s t h e pr oce d u r es t o wri t e pr og ra m s i n t h e seri al fl ash m e m o ry usi n g t h e d o wnloader in the ap plicable exam ples. 5.1 sample program configuration the sam p le program consists of three works p aces as listed in table 11. table 11 sample progra m configur a t ion work spa ce name des cription sh7 269 _spib s c_do wnl oad er builds the d o w nlo ade r in the proje c t of this workspa c e sh7 269 _spib s c_loa de r_prog builds the loader program in the project of this workspace sh7 269 _spib s c_ap p builds the application program in the project of this workspace. the downloader created in the [sh7269_spibsc_downloader] workspace, a batch file to boot the downloader, and the loader program created in the [sh7269_spibsc_loader_prog] workspace are registered in the project of th is workspace. use these items to write the loader program and applicat ion program in the serial flash memory.
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 53 of 58 feb 16, 2012 5.2 writing programs in th e serial flash memor y th is section d e scrib e s how to write th e l o a d e r pr og ram and appl i cat i o n p r o g ram i n t h e se r i al flash m e m o ry usi n g t h e [sh7269_s p ibs c_app] workspace. 5.2.1 registering the dow nl oad module and the batch file figure 15 s h ows t h e directory configur ation of the [s h7269_s p ibsc _app] workspace . downl o ad m odul es (a, b , cand e) and a bat c h fi l e ( d ) i n t h e fi gu re are re gi st ere d i n t h e p r o j ect . a n at t e nt i o n i s re qui red t o re gi st er t h e d o w nl oa d m odul es a an d b. a as ab s f ile is down lo a d e d only its d e bu g infor m atio n an d b as m o t file is d o w n lo a d e d on larg e-cap acity ram using offset specification as spi m u lti i/o bus space doe s not allo w downloa d ing i n to it directly. figure 16 and figu re 17 sh ow th e dow n l o a d ex am p les u s in g in t h e sam p le pr og r a m s . figure 15 [sh72 69_ spib sc_a pp] wor kspa ce dire ctory config uration 1. ch ang ing t h e do wn lo ad m o dule the downloa d m odule settin g is cha n ged in t h e deb u g se tt ings di al o g bo x whi c h i s o p e n ed by sel ect i ng debu g settin g in t h e debu g m e nu o f t h e hi gh -pe rf o rm ance embedde d wo r k s h o p . fo r t h e p r oce d ure t o regi st er t h e do w n l o a d m odul es, re fer t o t h e hi g h - pe r f o r m a nce em b e dde d wo r k s h op u s er ?s m a nual . 2. ch ang i ng t h e batch file th e b a tch file settin g reg i stered in th e proj ect is ch an g e d i n th e se t ba tc h file di al o g b o x . t h e fol l o w i ng p r oce d ure will o p e n th e set b a tc h file di al o g bo x. o n t h e vi e w m e nu i n t h e hi g h - p er fo rm ance em bedded wo r k s h o p , cl i c k th e co mma nd lin e to op en th e command line win d o w . ope n t h e se t b a tc h file di al o g bo x fr om t h e ba tch file p op- up m e n u on th e comm and line w i ndow . fo r th e p r oce d ure t o regi st er t h e bat c h fi l e , r e fer t o t h e hi g h - p er f o rm ance em bedded wo rks h op u s er ?s m a nual . \ sh 7269_ spibsc _ app | - sh 7269 _ s pib s c _ app | | - debug | | - sh 7269 _ s pibsc _ app . a bs | | - sh 7269 _ s pibsc _ app . m ot | | - inc | - s r c | - sf lash _ b oot | - sh 7269 _ s pibsc _ downloader . abs | - downloader . hdc | - sh 7269 _ s pibsc _ loade r _ prog . abs : w orks pace dir ecto ry : p roje ct d irect ory : : app lica tion prog ram exec ute file 1 ------ ------ ------ ------- a : ------ ------ ------ ------- b : : di recto ry t o st ore the comm on in clud e fi les : d irect ory to s tore the sou rce f iles : dire ctor y to stor e th e do wnlo ader and load er p rogr ams : dow nloa der exec ute f ile ----- ------ ------- ------ ------ ------ ------- ----- c : batch fil e to boo t th e do wnloa der --- ------ ------ ------ ------- ------ --- d : loa der p rogr am e xecu te f ile -- ------- ------ ------ ------ ------- ------ -- e a ppli cati on p rogra m ex ecut e fi le 2
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 54 of 58 feb 16, 2012 figure 16 example for registe ring th e do w n lo ad module as m ot file figure 17 example for registe ring th e do w n lo ad module as a bs file select ?elf/dwarf2? as the debug format set as below. offset = 04000000 file format = s-record select ?xxx.mot? and click modify check ?download debug information only? select ?xxx.abs? and click modify .
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 55 of 58 feb 16, 2012 5.2.2 procedures to writing programs th is section d e scrib e s how to write th e lo ad er p r o g ram an d th e app licatio n prog ram in th e serial flash m e m o ry u sin g th e [sh7269_s p ibs c_app] workspace. 1. co p y t h e [sh726 9_ sp ib sc_ a p p ] w o r k sp ace d i r ecto r y i n c:\w ork s p ace. 2. d oub le- c lick t h e [ sh72 69_ spibsc_ a pp].hw s in th e wor k spac e direct ory to a ctivate th e hi gh-perform ance em bedded w o rk shop . 3. on the b u ild m e nu i n hi gh - p er fo rm ance em bedded wo r k s h o p , sel ect t h e build all to bu ild th e pro j ect. th e ap p licatio n prog ram is g e n e rated . 4. on the deb ug m e nu i n hi gh - p er fo rm ance em bedded wo r k s h o p , sel ect t h e go t o co nn ect with th e target d e v ice. 5. after th e con n ectio n estab lish m en t, select th e command line on th e vi ew m e nu i n hi gh - p er fo rm ance embedde d w o rk shop to op en th e co mma n d line win d o w as s h ow n i n figure 18. 6. click th e run batch bu tton i n th e comm and line w i ndow to ex ecu t e the r e g i ster ed b a t c h f ile [ dow n l oad e r.hd c]. command line window r un b a tch bu tton figure 18 command li ne windo w a nd run batc h button
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 56 of 58 feb 16, 2012 7. whe n t h e batch file [downl oa der.hdc] is e x e c uted, all of the downloa d m o dules regist ered in the works p ace (loa der pr o g ram , appl i cat i on pr o g ram , an d d o w n l o a d er) a r e t r a n s f erred to r a m to execute t h e downl o ade r . as s h own in fig u r e 19 , t h e p r og r a m co un ter stop s at th e _ h a lt, wh en th e do wn lo ad er en ds n o r m al ly. th e p r og r a m co un ter stop s at th e _ e r r or , wh en th e do wn l o ad er end s in er ro r. a so ur ce f ile m a y ap p e ar w h en t h e [sh7 269 _sp i b s c_do wn lo ad er ] wo r k space di re ct ory i s c opi e d i n c : \ w o r k s pa ce. 8. wh en writin g i s co m p leted successfu lly, th e lo ad er p r o g ram and th e app licatio n p r og ram can b e ex ecu ted after reset g o . when the downloader ends normally, the program counter stops at the _halt. whe n t h e dow nloa d er ends i n err o r , the prog r a m co unter st o p s at the _e rr o r . figure 19 high-per f orm a nce embed ded wor ksh op windo w when the do w n lo ader en ds
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 57 of 58 feb 16, 2012 6. references ? so ftware m a n u al sh -2 a/s h 2 a - fpu s o ft ware m a nual re v. 3 . 0 0 the l a t e st ve rsi o n can be d o w nl oa ded f r om t h e r e nesas el e c t r o n i c s we bsi t e. ? user' s m a n u al fo r har d ware sh7 268 g r ou p, sh 726 9 gro u p u s er 's manual: h a rd w a r e r e v . 1 . 00 the l a t e st ve rsi o n can be d o w nl oa ded f r om t h e r e nesas el e c t r o n i c s we bsi t e.
SH7268/sh7269 group boot from the serial flash memory using spi multi i/o bus controller r01a n0 663e j01 01 rev. 1.01 page 58 of 58 feb 16, 2012 website and suppor t r e nesas el ect r oni cs w e bsi t e h ttp ://www.renesas.co m / inqu iries http://www.renesas.com /inqui ry all tradem arks and registere d tradem arks ar e the property of their res p ective owne rs.
a-1 revision record des c ription rev . da te page summar y 1.00 jul 11.11 ? first edition issued 1.01 feb 16.12 ? added sample code of sh726b
general precautions in the handling of mpu/mcu products th e fo llowing u s ag e n o t es are app licab le to all mpu/mcu p r od u c ts fro m ren e sas. fo r detailed u s ag e no tes o n th e pr o duct s c o ver e d by t h i s m a nual , refe r t o t h e rel e va nt s ect i o ns of t h e m a nu al . if t h e desc ri pt i o n s un der g e neral preca utions in the ha ndling of mpu/ mcu products and i n the body of t h e m a nual diffe r from each othe r, t h e descri ption in t h e body of the manual takes precede n ce. 1. han d ling of unused pin s han d le un used pin s in accord with the d i re ction s give n unde r hand ling of unu s e d pins in the manu al. ? the inp u t pin s of cmos p r odu cts a r e ge nerally in the high -impe dan ce state. in o peration with an unu sed pi n in the open -ci r cuit state, extra elect r oma g netic noi se i s indu ced in th e vicinity of lsi, an asso ciated sh oot-throug h current flows intern ally, and malfunctio n s occur d ue to the false re cog nition of the pin state as an in put si gnal be co me possibl e. unu s ed pi ns sho uld be ha ndle d as describe d un der han d ling of unu s ed pi ns in the ma n ual. 2. processin g at power-o n the state of the produ ct is undefin ed at the mome nt when po we r is sup plied. ? the state s of intern al circui ts in the lsi are ind etermi n ate and the st ates of re gist er settings a n d pins a r e u nde fined at the moment when power i s su p p lied. in a finished pro du c t whe r e the re set si gnal is a pplie d to the external re set pin, the states of pins are n o t guara n teed from th e moment wh en po we r is supplie d until the re set pr ocess is compl e ted. in a similar way, the states of pins in a p r od uc t that is re set by an o n -chip p o wer-on re set fun c tion are n o t guara n teed from th e moment wh en po we r is supplie d until the po we r rea c he s the level at whi c h resetting has b een specifie d. 3. prohibitio n of access to re se rved add r e s ses access to re served a ddresse s is p r ohi bited. ? the re se rved addresse s are provid ed for the possible future expa nsi on of functio n s. do n o t acce ss these a dd r e s se s; the co rre ct ope ration o f ls i is not guara n teed if they are a c cessed. 4. clo ck sig nal s after applying a reset, only rele ase the re set line after t he ope ratin g clo ck sign al h as be co me st able. whe n switchi ng the clo c k signal du rin g p r og ram ex e c u t ion, wait until the target clo ck sign al ha s stabili zed. ? when the clock signal is gene rated with an external resonator (or from an exter nal oscillator) duri ng a reset , ensure that the reset line i s only re l e ased after full st abilization of the clock signal. more over, wh en switchi ng to a clo ck sign al pro du c ed with an external re so nator (or by an exte rnal oscillator) whi le program ex ecution is in progress, wait until t he target clock signal is stabl e. 5. differe nces b etwee n prod ucts before chan g ing from on e pro d u c t to another, i.e. to one with a differe nt type number, confirm that the cha nge will n o t lead to pro b lem s . ? the characteristics of mpu/mcu in the same group but having different type numbers may differ because of the differences in internal memory capacity and layout pattern. when changing to products of different type numbers, implement a sy stem-evaluation test for each of the products.


▲Up To Search▲   

 
Price & Availability of SH7268

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X